#ifndef TREASUREWIDGET_H
#define TREASUREWIDGET_H

#include"ui_treasure.h"
#include<QValidator>
#include<QMap>

#include "serialize/treasure.h"
#include "serialize/fragment.h"

namespace Ui{
class TreasureWidget;
}

class TreasureWidget : public QWidget
{
    Q_OBJECT

public:
    explicit TreasureWidget(QWidget* p=0);
    ~TreasureWidget();

    void initialMap();
    inline void setFilePath(QString s){filePath = s;}
    inline void setWorkPath(QString s){workPath = s;}
    Treasure getTreasureFromUI();
    void displayTreasureToUI(Treasure& m);
    Treasure readTreasureFromFile();
    bool saveTreasureToFile();
    void clearUI();

    static void exportToBinary(QString workspacepath);
    static void exportToXML(QString workspacepath);
    static void importFromXML(QString workspacepath,QString xmlFile);

    void addTreeItems(QList<QTreeWidgetItem*> items);

    Ui::TreasureWidget* ui;

public slots:
    void s_fragmentItemDoubleClicked(QTreeWidgetItem* item,int col);
    void s_cellDoubleClicked(int row, int column);

private:
    QString filePath;
    QString workPath;
    QMap<int,QString> fragmentMap;
    void setInputMask();
};

#endif // TREASUREWIDGET_H
